﻿#include "FITKAbaqusAdaptorLoad.h"
#include "InpKeyLineSpliter.h"
#include "FITKAbaqusINPReader.h"
#include "FITKAbaqusINPWriter.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaAbstractLoad.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaLoadConcentratedForce.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaLoadPressure.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaLoadMoment.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaLoadBodyForce.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaLoadGravity.h"
#include "FITK_Kernel/FITKAppFramework/FITKMessage.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaStepManager.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaAssembly.h"
#include "FITK_Component/FITKAbaqusData/FITKAbaqusPart.h"
#include "FITK_Component/FITKAbaqusData/FITKDataCase.h"
#include "FITK_Interface/FITKInterfaceModel/FITKComponentManager.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaAmplitudeManager.h"
#include "FITK_Interface/FITKInterfacePhysics/FITKAbstractLoadBC.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaLoadManager.h"
#include "FITK_Interface/FITKInterfacePhysics/FITKAbstractFields.h"
#include "FITK_Interface/FITKInterfaceModel/FITKAssInstanceTR.h"
#include "FITK_Interface/FITKInterfacePhysics/FITKAnalyticalExpressField.h"
#include "FITK_Kernel/FITKPython/FITKPythonInterface.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaMeshPartVTK.h"
#include "FITK_Interface/FITKInterfaceModel/FITKAbstractElement.h"
#include "FITK_Interface/FITKInterfaceModel/FITKMeshSurfaceElement.h"
#include <QtCore/qmath.h>
#include <QTextStream>
#include <QList>
#include <QDebug>
//命名空间
namespace IO
{
    QString FITKAbaqusAdaptorLoad::getAdaptorClass()
    {
        return "IO::FITKAbaqusAdaptorLoad";
    }

    void FITKAbaqusAdaptorLoad::setLoadDeactiveStepR(QString word, int stepId)
    {
        if (!_caseData)return;
        //获取管理器
        auto loadManager = _caseData->getLoadManager();
        if (!loadManager)return;
        int count = loadManager->getDataCount();
        //类型链表
        QList<Interface::FITKAbaAbstractLoad::FITKAbaLoadType> typeList;
        if (word == "cload")
            typeList << Interface::FITKAbaAbstractLoad::FITKAbaLoadType::ConcentratedForce
            << Interface::FITKAbaAbstractLoad::FITKAbaLoadType::Moment;
        else if (word == "dload")
            typeList << Interface::FITKAbaAbstractLoad::FITKAbaLoadType::BodyForce 
            << Interface::FITKAbaAbstractLoad::FITKAbaLoadType::Gravity;
        else if (word == "dsload")
            typeList << Interface::FITKAbaAbstractLoad::FITKAbaLoadType::Pressure;
        if (typeList.isEmpty())return;
        //获取类型一致的载荷在当前step中取消激活
        for (int i = 0; i < count; ++i)
        {
            Interface::FITKAbaAbstractLoad* load = dynamic_cast<Interface::FITKAbaAbstractLoad*>(loadManager->getDataByIndex(i));
            if (!load || !typeList.contains(load->getLoadType()))continue;
            if (load->getCreatedStep() == stepId || load->getDeactiveStep() != -1) continue;
            load->setDeactiveStep(stepId);
        }
    }

    bool FITKAbaqusAdaptorLoad::isValueEmpty()
    {
        return _isValueEmp;
    }

    bool FITKAbaqusAdaptorLoad::adaptR()
    {
        //读取
        Interface::FITKAbaAbstractLoad* load = dynamic_cast<Interface::FITKAbaAbstractLoad*>(_dataObj);
        if (!load || !_reader || !_caseData || _keywordsLine.isEmpty())return false;
        bool readOK = false;
        //获取类型
        Interface::FITKAbaAbstractLoad::FITKAbaLoadType type = load->getLoadType();
        if (type == Interface::FITKAbaAbstractLoad::FITKAbaLoadType::ConcentratedForce)
            readOK = this->cLoadConcentratedForceR();
        else if (type == Interface::FITKAbaAbstractLoad::FITKAbaLoadType::Moment)
            readOK = this->cLoadMomentR();
        else if (type == Interface::FITKAbaAbstractLoad::FITKAbaLoadType::Pressure)
            readOK = this->dsLoadPressureR();
        else if (type == Interface::FITKAbaAbstractLoad::FITKAbaLoadType::BodyForce)
            readOK = this->dLoadBodyForceR();
        else if (type == Interface::FITKAbaAbstractLoad::FITKAbaLoadType::Gravity)
            readOK = this->dLoadGravityR();
        return readOK;
    }
    bool FITKAbaqusAdaptorLoad::adaptW()
    {
        //写出
        Interface::FITKAbaAbstractLoad* load = dynamic_cast<Interface::FITKAbaAbstractLoad*>(_dataObj);
        if (!load || !_writer || !_caseData)return false;
        bool writerOK = false;
        Interface::FITKAbaAbstractLoad::FITKAbaLoadType type = load->getLoadType();
        if (type == Interface::FITKAbaAbstractLoad::FITKAbaLoadType::ConcentratedForce)
            writerOK = this->cLoadConcentratedForceW();
        else if (type == Interface::FITKAbaAbstractLoad::FITKAbaLoadType::Moment)
            writerOK = this->cLoadMomentW();
        else if (type == Interface::FITKAbaAbstractLoad::FITKAbaLoadType::Pressure)
            writerOK = this->dsLoadPressureW();
        else if (type == Interface::FITKAbaAbstractLoad::FITKAbaLoadType::BodyForce)
            writerOK = this->dLoadBodyForceW();
        else if (type == Interface::FITKAbaAbstractLoad::FITKAbaLoadType::Gravity)
            writerOK = this->dLoadGravityW();

        return writerOK;
    }

    void FITKAbaqusAdaptorLoad::setCaseData(AbaqusData::FITKDataCase* caseData)
    {
        _caseData = caseData;
        _tool.setCaseData(_caseData);
    }

    void FITKAbaqusAdaptorLoad::setLineKeywords(QString line)
    {
        //设置行数据
        _keywordsLine = line;
    }

    void FITKAbaqusAdaptorLoad::setWriterData(QString op, int stepId)
    {
        _op = op;
        _stepId = stepId;
    }

    bool FITKAbaqusAdaptorLoad::cLoadConcentratedForceR()
    {
        //集中力的数据存储
        Interface::FITKAbaLoadConcentratedForce* cLoad = dynamic_cast<Interface::FITKAbaLoadConcentratedForce*>(_dataObj);
        auto loadManager = _caseData->getLoadManager();
        if (!loadManager)return false;
        if (!_reader || !_caseData || !cLoad)return false;
        QString name = loadManager->checkName("CFORCE-1");
        cLoad->setDataObjectName(name);
        //处理关键字
        InpKeyLineSpliter spl(_keywordsLine, _reader);
        //获取幅值曲线的名称
        if (_caseData->getAmplitudeManager())
        {
            auto ampData = _caseData->getAmplitudeManager()->getDataByName(spl["amplitude"]);
            if (ampData)
                cLoad->setAmplitudeId(ampData->getDataObjectID());
        }
        if (spl.hasKey("follower"))
            cLoad->setFlowNodalRotation(true);
        //回退一行,处理数据
        _reader->backLine();
        QString line = _reader->readLine();
        QStringList str = line.split(',');
        if (str.size() < 3)return false;
        bool ok = false;
        int instanceId = -1;
        int setID = _tool.createSetByStrData(str.at(0).trimmed(), Interface::FITKModelEnum::FITKModelSetType::FMSNode, instanceId);
        if (setID == -1)
            setID = _tool.getSetIDByName(str.at(0).trimmed(), -1, instanceId);
        if (setID == -1)return false;
        //获取是集中力还是弯矩
        int num = str.at(1).trimmed().toInt();
        if (!(num > 0 && num <= 3))return false;
        double value = str.at(2).trimmed().toDouble(&ok);
        if (!ok)return false;
        cLoad->setComponent(setID);
        cLoad->setModel(instanceId);
        if (num == 1)
            cLoad->setCF1(value);
        else if (num == 2)
            cLoad->setCF2(value);
        else if (num == 3)
            cLoad->setCF3(value);
        //记录数据是否为空
        if (fabsl(value) < 1e-15)
            _isValueEmp = true;
        //机制处理
        //获取管理器
        int stepId = cLoad->getCreatedStep();
        int count = loadManager->getDataCount();
        //获取类型一致的载荷在当前step中取消激活
        for (int i = 0; i < count; ++i)
        {
            Interface::FITKAbaLoadConcentratedForce* loadData = dynamic_cast<Interface::FITKAbaLoadConcentratedForce*>(loadManager->getDataByIndex(i));
            if (!loadData || loadData->getDeactiveStep() != -1 || cLoad->getLoadType() != loadData->getLoadType())continue;
            if (loadData->getCreatedStep() == stepId || setID != loadData->getComponentID()) continue;
            if (num == 1 && fabsl(loadData->getCF1()) > 1e-15)
                loadData->setDeactiveStep(stepId);
            else if (num == 2 && fabsl(loadData->getCF2()) > 1e-15)
                loadData->setDeactiveStep(stepId);
            else if (num == 3 && fabsl(loadData->getCF3()) > 1e-15)
                loadData->setDeactiveStep(stepId);
        }
        return true;
    }

    bool FITKAbaqusAdaptorLoad::cLoadMomentR()
    {
        //弯矩的数据存储
        Interface::FITKAbaLoadMoment* cLoad = dynamic_cast<Interface::FITKAbaLoadMoment*>(_dataObj);
        auto loadManager = _caseData->getLoadManager();
        if (!loadManager)return false;
        if (!_reader || !_caseData || !cLoad)return false;
        QString name = loadManager->checkName("MOMENT-1");
        cLoad->setDataObjectName(name);
        //处理关键字
        InpKeyLineSpliter spl(_keywordsLine, _reader);
        //获取幅值曲线的名称
        if (_caseData->getAmplitudeManager())
        {
            auto ampData = _caseData->getAmplitudeManager()->getDataByName(spl["amplitude"]);
            if (ampData)
                cLoad->setAmplitudeId(ampData->getDataObjectID());
        }
        if (spl.hasKey("follower")){ }
        //回退一行,处理数据
        _reader->backLine();
        QString line = _reader->readLine();
        QStringList str = line.split(',');
        if (str.size() < 3)return false;
        bool ok = false;
        int instanceId = -1;
        int setID = _tool.createSetByStrData(str.at(0).trimmed(), Interface::FITKModelEnum::FITKModelSetType::FMSNode, instanceId);
        if (setID == -1)
            setID = _tool.getSetIDByName(str.at(0).trimmed(), -1, instanceId);
        if (setID == -1)return false;
        //获取是集中力还是弯矩
        int num = str.at(1).trimmed().toInt();
        if (!(num > 3 && num <= 6))return false;
        double value = str.at(2).trimmed().toDouble(&ok);
        if (!ok)return false;
        cLoad->setComponent(setID);
        cLoad->setModel(instanceId);
        if (num == 4)
            cLoad->setCM1(value);
        else if (num == 5)
            cLoad->setCM2(value);
        else if (num == 6)
            cLoad->setCM3(value);
        //记录数据是否为空
        if (fabsl(value) < 1e-15)
            _isValueEmp = true;
        //机制处理
        //获取管理器
        int stepId = cLoad->getCreatedStep();
        int count = loadManager->getDataCount();
        //获取类型一致的载荷在当前step中取消激活
        for (int i = 0; i < count; ++i)
        {
            Interface::FITKAbaLoadMoment* loadData = dynamic_cast<Interface::FITKAbaLoadMoment*>(loadManager->getDataByIndex(i));
            if (!loadData || loadData->getDeactiveStep() != -1 || cLoad->getLoadType() != loadData->getLoadType())continue;
            if (loadData->getCreatedStep() == stepId || setID != loadData->getComponentID()) continue;
            if (num == 4 && fabsl(loadData->getCM1()) > 1e-15)
                loadData->setDeactiveStep(stepId);
            else if (num == 5 && fabsl(loadData->getCM2()) > 1e-15)
                loadData->setDeactiveStep(stepId);
            else if (num == 6 && fabsl(loadData->getCM3()) > 1e-15)
                loadData->setDeactiveStep(stepId);
        }

        return true;
    }

    bool FITKAbaqusAdaptorLoad::dsLoadPressureR()
    {
        //表面压强载荷的数据存储
        Interface::FITKAbaLoadPressure* dsLoad = dynamic_cast<Interface::FITKAbaLoadPressure*>(_dataObj);
        auto loadManager = _caseData->getLoadManager();
        if (!loadManager)return false;
        if (!_reader || !_caseData || !dsLoad)return false;
        QString name = loadManager->checkName("SURFFORCE-1");
        dsLoad->setDataObjectName(name);
        //处理关键字
        InpKeyLineSpliter spl(_keywordsLine, _reader);
        //获取幅值曲线的名称
        if (_caseData->getAmplitudeManager())
        {
            auto ampData = _caseData->getAmplitudeManager()->getDataByName(spl["amplitude"]);
            if (ampData)
                dsLoad->setAmplitudeId(ampData->getDataObjectID());
        }
        //回退一行,处理数据
        _reader->backLine();
        QString line = _reader->readLine();
        QStringList str = line.split(',');
        if (str.size() < 3)return false;
        bool ok = false;
        //载荷大小
        double value = str.at(2).trimmed().toDouble(&ok);
        if (!ok)return false;
        if (value < 0)
            str[1] = QString("-%1").arg(str.at(1).trimmed());
        int instanceId = -1;
        int surfID = _tool.createSurfByStrData(str.at(0).trimmed(), str.at(1).trimmed(), Interface::FITKMeshSurface::MeshSurfaceType::SurEle, instanceId);
        if (surfID == -1)
            surfID = _tool.getSurfIDByName(str.at(0).trimmed(), -1, instanceId);
        if (surfID == -1)return false;

        dsLoad->setModel(instanceId);
        dsLoad->setComponent(surfID);
        dsLoad->setPressure(value);

        if (fabsl(value) < 1e-15)
            _isValueEmp = true;
        //机制处理
        //获取管理器
        int stepId = dsLoad->getCreatedStep();
        int count = loadManager->getDataCount();
        //获取类型一致的载荷在当前step中取消激活
        for (int i = 0; i < count; ++i)
        {
            Interface::FITKAbaLoadPressure* loadData = dynamic_cast<Interface::FITKAbaLoadPressure*>(loadManager->getDataByIndex(i));
            if (!loadData || loadData->getDeactiveStep() != -1 || dsLoad->getLoadType() != loadData->getLoadType())continue;
            if (loadData->getCreatedStep() == stepId || surfID != loadData->getComponentID()) continue;
            if (fabsl(loadData->getPressure()) > 1e-15)
                loadData->setDeactiveStep(stepId);
        }
        return true;
    }

    bool FITKAbaqusAdaptorLoad::dLoadBodyForceR()
    {
        //体力的数据存储
        Interface::FITKAbaLoadBodyForce* dLoad = dynamic_cast<Interface::FITKAbaLoadBodyForce*>(_dataObj);
        auto loadManager = _caseData->getLoadManager();
        if (!loadManager)return false;
        if (!_reader || !_caseData || !dLoad)return false;
        QString name = loadManager->checkName("BODYFORCE-1");
        dLoad->setDataObjectName(name);
        //处理关键字
        InpKeyLineSpliter spl(_keywordsLine, _reader);
        //获取幅值曲线的名称
        if (_caseData->getAmplitudeManager())
        {
            auto ampData = _caseData->getAmplitudeManager()->getDataByName(spl["amplitude"]);
            if (ampData)
                dLoad->setAmplitudeId(ampData->getDataObjectID());
        }
        //回退一行,处理数据
        _reader->backLine();
        QString line = _reader->readLine();
        QStringList str = line.split(',');
        if (str.size() < 3)return false;
        bool ok = false;
        int instanceId = -1;
        int setID = _tool.createSetByStrData(str.at(0).trimmed(), Interface::FITKModelEnum::FITKModelSetType::FMSElem, instanceId);
        if (setID == -1)
            setID = _tool.getSetIDByName(str.at(0).trimmed(), -1, instanceId);
        if (setID == -1)return false;
        //获取集中力的参数
        QString type = str.at(1).trimmed().toLower();
        if (!(type == "bx" || type == "by" || type == "bz"))return false;
        double value = str.at(2).trimmed().toDouble(&ok);
        if (!ok)return false;
        dLoad->setComponent(setID);
        dLoad->setModel(instanceId);
        if (type == "bx")
            dLoad->setComponent1(value);
        else if (type == "by")
            dLoad->setComponent2(value);
        else if (type == "bz")
            dLoad->setComponent3(value);

        if (fabsl(value) < 1e-15)
            _isValueEmp = true;

        //机制处理
        //获取管理器
        int stepId = dLoad->getCreatedStep();
        int count = loadManager->getDataCount();
        //获取类型一致的载荷在当前step中取消激活
        for (int i = 0; i < count; ++i)
        {
            Interface::FITKAbaLoadBodyForce* loadData = dynamic_cast<Interface::FITKAbaLoadBodyForce*>(loadManager->getDataByIndex(i));
            if (!loadData || loadData->getDeactiveStep() != -1 || dLoad->getLoadType() != loadData->getLoadType())continue;
            if (loadData->getCreatedStep() == stepId || setID != loadData->getComponentID()) continue;
            if (type == "bx" && fabsl(loadData->getComponent1()) > 1e-15)
                loadData->setDeactiveStep(stepId);
            else if (type == "by" && fabsl(loadData->getComponent2()) > 1e-15)
                loadData->setDeactiveStep(stepId);
            else if (type == "bz" && fabsl(loadData->getComponent3()) > 1e-15)
                loadData->setDeactiveStep(stepId);
        }
        return true;
    }

    bool FITKAbaqusAdaptorLoad::dLoadGravityR()
    {
        Interface::FITKAbaLoadGravity* dLoad = dynamic_cast<Interface::FITKAbaLoadGravity*>(_dataObj);
        auto loadManager = _caseData->getLoadManager();
        if (!loadManager)return false;
        if (!_reader || !_caseData || !dLoad)return false;
        QString name = loadManager->checkName("GRAVITY-1");
        dLoad->setDataObjectName(name);
        //处理关键字
        InpKeyLineSpliter spl(_keywordsLine, _reader);
        //获取幅值曲线的名称
        if (_caseData->getAmplitudeManager())
        {
            auto ampData = _caseData->getAmplitudeManager()->getDataByName(spl["amplitude"]);
            if (ampData)
                dLoad->setAmplitudeId(ampData->getDataObjectID());
        }
        //回退一行,处理数据
        _reader->backLine();
        QString line = _reader->readLine();
        QStringList str = line.split(',');
        if (str.size() < 6)return false;
        bool ok = false;
        int setID = 0;
        //设置set单元集
        if(!str.at(0).trimmed().isEmpty())
        {
            dLoad->setWholeModel(false);
            int instanceId = -1;
            setID = _tool.createSetByStrData(str.at(0).trimmed(), Interface::FITKModelEnum::FITKModelSetType::FMSElem, instanceId);
            if (setID == -1)
                setID = _tool.getSetIDByName(str.at(0).trimmed(), -1, instanceId);
            if (setID == -1)return false;
            dLoad->setComponent(setID);
            dLoad->setModel(instanceId);
        }        
        //获取重力的参数
        QString type = str.at(1).trimmed().toLower();
        if (type != "grav")return false;
        double value = str.at(2).trimmed().toDouble(&ok);
        if (!ok)return false;
        double x = str.at(3).trimmed().toDouble(&ok);
        if (!ok)return false;
        double y = str.at(4).trimmed().toDouble(&ok);
        if (!ok)return false;
        double z = str.at(5).trimmed().toDouble(&ok);
        if (!ok)return false;
        dLoad->setComponent1(value * x);
        dLoad->setComponent2(value * y);
        dLoad->setComponent3(value * z);

        //机制处理
        //获取管理器
        int stepId = dLoad->getCreatedStep();
        int count = loadManager->getDataCount();
        //获取类型一致的载荷在当前step中取消激活
        for (int i = 0; i < count; ++i)
        {
            Interface::FITKAbaLoadGravity* loadData = dynamic_cast<Interface::FITKAbaLoadGravity*>(loadManager->getDataByIndex(i));
            if (!loadData || loadData->getDeactiveStep() != -1 || dLoad->getLoadType() != loadData->getLoadType())continue;
            if (loadData->getCreatedStep() == stepId) continue;
            bool isWho = dLoad->isWholeModel();
            if (isWho != loadData->isWholeModel())continue;
            if (!isWho)
                if (setID != loadData->getComponentID())continue;
            loadData->setDeactiveStep(stepId);
        }
        return true;
    }

    bool FITKAbaqusAdaptorLoad::cLoadConcentratedForceW()
    {
        //集中力的数据存储
        Interface::FITKAbaLoadConcentratedForce* load = dynamic_cast<Interface::FITKAbaLoadConcentratedForce*>(_dataObj);
        if (!_writer || !_caseData || !load)return false;
        QTextStream* stream = _writer->getStream();
        QString inforString = QString("** Name: %1  Type: %2").arg(load->getDataObjectName()).arg("Concentrated force");
        Interface::FITKAbstractFiled* field = load->getField();
        if (field)
            inforString += QString(" Using Field: %1").arg(field->getDataObjectName());
        *stream << inforString << endl;
        //写出cload
        QString lineOne = "*Cload";
        if (!_op.isEmpty())
            lineOne += _op;
        //输出取消激活
        if (_stepId == -1)
        {
            *stream << lineOne << endl;
            return true;
        }
        if (load->getFlowNodalRotation())
            lineOne += QString(", follower");
        auto ampData = _caseData->getAmplitudeManager()->getDataByID(load->getAmplitudeId(_stepId));
        if (ampData)
        {
            QString ampName = ampData->getDataObjectName();
            ampName = ampName.contains(' ') ? QString("\"%1\"").arg(ampName) : ampName;
            lineOne += QString(", amplitude=%1").arg(ampName);
        }
        *stream << lineOne << endl;
        //获取上一级stepId
        Interface::FITKAbaStepManager* stepManager = _caseData->getStepManager();
        int superiorStepId = -1;
        if (load->getCreatedStep() != _stepId && stepManager && load->isModifiedInStep(_stepId))
        {
            int index = stepManager->getDataIndex(stepManager->getDataByID(_stepId)) - 1;
            Interface::FITKAbaAbstractStep* superiorStep = stepManager->getDataByIndex(index);
            if (superiorStep)
                superiorStepId = superiorStep->getDataObjectID();
        }
        //获取set
        Interface::FITKModelSet* set = dynamic_cast<Interface::FITKModelSet*> (load->getComponentObj());
        if (!set)return false;
        QString setName = set->getDataObjectName();
        setName = setName.contains(' ') ? QString("\"%1\"").arg(setName) : setName;
        Interface::FITKAbstractModel* modelData = load->getModelObj();
        if (!modelData) return false;
        if (load->getModelID() != set->getAbsModelID() && modelData->getAbsModelType() == Interface::FITKModelEnum::AbsModelType::AssInstance)
        {
            QString name = load->getModelObj()->getDataObjectName();
            name = name.contains(' ') ? QString("\"%1\"").arg(name) : name;
            setName = name + "." + setName;
        }
        QPair<QString, double> cf[3]{ QPair<QString, double>("", load->getCF1(_stepId)), QPair<QString, double>("", load->getCF2(_stepId)), QPair<QString, double>("", load->getCF3(_stepId)) };
        //是否写出1
        if (fabsl(cf[0].second) > 1e-15 || (superiorStepId != -1 && fabsl(cf[0].second - load->getCF1(superiorStepId)) > 1e-15))
            cf[0].first = "1";
        //是否写出2
        if (fabsl(cf[1].second) > 1e-15 || (superiorStepId != -1 && fabsl(cf[1].second - load->getCF2(superiorStepId)) > 1e-15))
            cf[1].first = "2";
        //是否写出3
        if (fabsl(cf[2].second) > 1e-15 || (superiorStepId != -1 && fabsl(cf[2].second - load->getCF3(superiorStepId)) > 1e-15))
            cf[2].first = "3";
        //场不存在
        if (!field)
        {
            //写出
            for (int i = 0; i < 3; ++i)
            {
                if (cf[i].first.isEmpty())continue;
                *stream << QString("%1, %2, %3").arg(setName).arg(cf[i].first).arg(_writer->double2String(cf[i].second, 9, 0)) << endl;
            }
            return true;
        }

        //存在场时，需要转换
        Interface::FITKAbstractFiled::FITKFieldType fieldType = field->getFieldType();
        if (fieldType == Interface::FITKAbstractFiled::FITKFieldType::FFTAnalytical)
        {
            QStringList nameList;
            QList<double> resultList;
            if (!this->getAnalyticalDataBySetData(set, Interface::FITKModelEnum::FITKModelSetType::FMSNode, nameList, resultList))
                return false;
            for (int i = 0; i < nameList.size(); ++i)
            {
                QString name = nameList.at(i);
                double result = resultList.at(i);
                for (int j = 0; j < 3; ++j)
                {
                    if (cf[j].first.isEmpty())continue;
                    *stream << QString("%1, %2, %3").arg(name).arg(cf[j].first).arg(_writer->double2String(cf[j].second * result)) << endl;
                }
            }
            
        }
        return true;
    }

    bool FITKAbaqusAdaptorLoad::cLoadMomentW()
    {
        //弯矩的数据存储
        Interface::FITKAbaLoadMoment* load = dynamic_cast<Interface::FITKAbaLoadMoment*>(_dataObj);
        if (!_writer || !_caseData || !load)return false;
        QTextStream* stream = _writer->getStream();
        QString inforString = QString("** Name: %1  Type: %2").arg(load->getDataObjectName()).arg("Moment");
        Interface::FITKAbstractFiled* field = load->getField();
        if (field)
        {
            inforString += QString(" Using Field: %1").arg(field->getDataObjectName());
        }
        *stream << inforString << endl;
        //写出cload
        QString lineOne = "*Cload";
        if (!_op.isEmpty())
            lineOne += _op;
        //输出取消激活
        if (_stepId == -1)
        {
            *stream << lineOne << endl;
            return true;
        }
        auto ampData = _caseData->getAmplitudeManager()->getDataByID(load->getAmplitudeId(_stepId));
        if (ampData)
        {
            QString ampName = ampData->getDataObjectName();
            ampName = ampName.contains(' ') ? QString("\"%1\"").arg(ampName) : ampName;
            lineOne += QString(", amplitude=%1").arg(ampName);
        }
        *stream << lineOne << endl;
        //获取上一级stepId
        Interface::FITKAbaStepManager* stepManager = _caseData->getStepManager();
        int superiorStepId = -1;
        if (load->getCreatedStep() != _stepId && stepManager && load->isModifiedInStep(_stepId))
        {
            int index = stepManager->getDataIndex(stepManager->getDataByID(_stepId)) - 1;
            Interface::FITKAbaAbstractStep* superiorStep = stepManager->getDataByIndex(index);
            if (superiorStep)
                superiorStepId = superiorStep->getDataObjectID();
        }
        //获取set
        Interface::FITKModelSet* set = dynamic_cast<Interface::FITKModelSet*> (load->getComponentObj());
        if (!set)return false;
        QString setName = set->getDataObjectName();
        setName = setName.contains(' ') ? QString("\"%1\"").arg(setName) : setName;
        Interface::FITKAbstractModel* modelData = load->getModelObj();
        if (!modelData) return false;
        if (load->getModelID() != set->getAbsModelID() && modelData->getAbsModelType() == Interface::FITKModelEnum::AbsModelType::AssInstance)
        {
            QString name = load->getModelObj()->getDataObjectName();
            name = name.contains(' ') ? QString("\"%1\"").arg(name) : name;
            setName = name + "." + setName;
        }
        QPair<QString, double> cf[3]{ QPair<QString, double>("", load->getCM1(_stepId)), QPair<QString, double>("", load->getCM2(_stepId)), QPair<QString, double>("", load->getCM3(_stepId)) };
        //是否写出4
        if (fabsl(cf[0].second) > 1e-15 || (superiorStepId != -1 && fabsl(cf[0].second - load->getCM1(superiorStepId)) > 1e-15))
            cf[0].first = "4";
        //是否写出5
        if (fabsl(cf[1].second) > 1e-15 || (superiorStepId != -1 && fabsl(cf[1].second - load->getCM2(superiorStepId)) > 1e-15))
            cf[1].first = "5";
        //是否写出6
        if (fabsl(cf[2].second) > 1e-15 || (superiorStepId != -1 && fabsl(cf[2].second - load->getCM3(superiorStepId)) > 1e-15))
            cf[2].first = "6";
        //场不存在
        if (!field)
        {
            //写出
            for (int i = 0; i < 3; ++i)
            {
                if (cf[i].first.isEmpty())continue;
                *stream << QString("%1, %2, %3").arg(setName).arg(cf[i].first).arg(_writer->double2String(cf[i].second, 9, 0)) << endl;
            }
            return true;
        }
        //存在场时，需要转换
        Interface::FITKAbstractFiled::FITKFieldType fieldType = field->getFieldType();
        if (fieldType == Interface::FITKAbstractFiled::FITKFieldType::FFTAnalytical)
        {
            QStringList nameList;
            QList<double> resultList;
            if (!this->getAnalyticalDataBySetData(set, Interface::FITKModelEnum::FITKModelSetType::FMSNode, nameList, resultList))
                return false;
            for (int i = 0; i < nameList.size(); ++i)
            {
                QString name = nameList.at(i);
                double result = resultList.at(i);
                for (int j = 0; j < 3; ++j)
                {
                    if (cf[j].first.isEmpty())continue;
                    *stream << QString("%1, %2, %3").arg(name).arg(cf[j].first).arg(_writer->double2String(cf[j].second * result)) << endl;
                }
            }
        }
        return true;
    }

    bool FITKAbaqusAdaptorLoad::dsLoadPressureW()
    {
        //表面压力载荷数据存储
        Interface::FITKAbaLoadPressure* load = dynamic_cast<Interface::FITKAbaLoadPressure*>(_dataObj);
        if (!_writer || !_caseData || !load)return false;
        QTextStream* stream = _writer->getStream();
        QString inforString = QString("** Name: %1  Type: %2").arg(load->getDataObjectName()).arg("Pressure");
        Interface::FITKAbstractFiled* field = load->getField();
        if (field)
        {
            inforString += QString(" Using Field: %1").arg(field->getDataObjectName());
        }
        *stream << inforString << endl;
        //写出cload
        QString lineOne = "*Dsload";
        if (field)
            lineOne = "*Dload";
        if (!_op.isEmpty())
            lineOne += _op;
        //输出取消激活
        if (_stepId == -1)
        {
            *stream << lineOne << endl;
            return true;
        }
        auto ampData = _caseData->getAmplitudeManager()->getDataByID(load->getAmplitudeId(_stepId));
        if (ampData)
        {
            QString ampName = ampData->getDataObjectName();
            ampName = ampName.contains(' ') ? QString("\"%1\"").arg(ampName) : ampName;
            lineOne += QString(", amplitude=%1").arg(ampName);
        }
        *stream << lineOne << endl;
        //获取surf
        Interface::FITKMeshSurfaceElement* surf = dynamic_cast<Interface::FITKMeshSurfaceElement*> (load->getComponentObj());
        if (!surf)return false;
        QString setName = surf->getDataObjectName();
        setName = setName.contains(' ') ? QString("\"%1\"").arg(setName) : setName;
        if (load->getModelObj() && load->getModelID() != surf->getAbsModelID() && load->getModelObj()->getAbsModelType() == Interface::FITKModelEnum::AbsModelType::AssInstance)
        {
            QString name = load->getModelObj()->getDataObjectName();
            name = name.contains(' ') ? QString("\"%1\"").arg(name) : name;
            setName = name + "." + setName;
        }
        double pressureValue = load->getPressure(_stepId);
        if (!field)
        {
            *stream << setName << ", " << "P, " << _writer->double2String(pressureValue, 9, 0) << endl;
            return true;
        }
        //存在场时，需要转换
        Interface::FITKAbstractFiled::FITKFieldType fieldType = field->getFieldType();
        if (fieldType == Interface::FITKAbstractFiled::FITKFieldType::FFTAnalytical)
        {
            QStringList polygonStringTypeList;
            QStringList nameList;
            QList<double> resultList;
            if (!this->getAnalyticalDataBySurfData(surf, Interface::FITKMeshSurface::MeshSurfaceType::SurEle, polygonStringTypeList, nameList, resultList))
                return false;
            for (int i = 0; i < nameList.size(); ++i)
            {
                QString name = nameList.at(i);
                double result = resultList.at(i);
                QString polygonString = polygonStringTypeList.at(i);
                *stream << QString("%1, %2, %3").arg(name).arg(polygonString).arg(_writer->double2String(pressureValue * result, 9, 0)) << endl;
            }
        }
        return true;
    }

    bool FITKAbaqusAdaptorLoad::dLoadBodyForceW()
    {
        //体力的数据存储
        Interface::FITKAbaLoadBodyForce* load = dynamic_cast<Interface::FITKAbaLoadBodyForce*>(_dataObj);
        if (!_writer || !_caseData || !load)return false;
        QTextStream* stream = _writer->getStream();
        QString inforString = QString("** Name: %1  Type: %2").arg(load->getDataObjectName()).arg("Body force");
        Interface::FITKAbstractFiled* field = load->getField();
        if (field)
            inforString += QString(" Using Field: %1").arg(field->getDataObjectName());
        *stream << inforString << endl;
        //写出dload
        QString lineOne = "*Dload";
        if (!_op.isEmpty())
            lineOne += _op;
        //输出取消激活
        if (_stepId == -1)
        {
            *stream << lineOne << endl;
            return true;
        }
        auto ampData = _caseData->getAmplitudeManager()->getDataByID(load->getAmplitudeId(_stepId));
        if (ampData)
        {
            QString ampName = ampData->getDataObjectName();
            ampName = ampName.contains(' ') ? QString("\"%1\"").arg(ampName) : ampName;
            lineOne += QString(", amplitude=%1").arg(ampName);
        }
        *stream << lineOne << endl;
        //获取上一级stepId
        Interface::FITKAbaStepManager* stepManager = _caseData->getStepManager();
        int superiorStepId = -1;
        if (load->getCreatedStep() != _stepId && stepManager && load->isModifiedInStep(_stepId))
        {
            int index = stepManager->getDataIndex(stepManager->getDataByID(_stepId)) - 1;
            Interface::FITKAbaAbstractStep* superiorStep = stepManager->getDataByIndex(index);
            if (superiorStep)
                superiorStepId = superiorStep->getDataObjectID();
        }
        //获取set
        Interface::FITKModelSet* set = dynamic_cast<Interface::FITKModelSet*> (load->getComponentObj());
        if (!set)return false;
        QString setName = set->getDataObjectName();
        setName = setName.contains(' ') ? QString("\"%1\"").arg(setName) : setName;
        Interface::FITKAbstractModel* modelData = load->getModelObj();
        if (!modelData) return false;
        if (load->getModelID() != set->getAbsModelID() && modelData->getAbsModelType() == Interface::FITKModelEnum::AbsModelType::AssInstance)
        {
            QString name = load->getModelObj()->getDataObjectName();
            name = name.contains(' ') ? QString("\"%1\"").arg(name) : name;
            setName = name + "." + setName;
        }
        QPair<QString, double> cf[3]{ QPair<QString, double>("", load->getComponent1(_stepId)), QPair<QString, double>("", load->getComponent2(_stepId)), QPair<QString, double>("", load->getComponent3(_stepId)) };
        //是否写出BX
        if (fabsl(cf[0].second) > 1e-15 || (superiorStepId != -1 && fabsl(cf[0].second - load->getComponent1(superiorStepId)) > 1e-15))
            cf[0].first = "BX";
        //是否写出BY
        if (fabsl(cf[1].second) > 1e-15 || (superiorStepId != -1 && fabsl(cf[1].second - load->getComponent2(superiorStepId)) > 1e-15))
            cf[1].first = "BY";
        //是否写出BZ
        if (fabsl(cf[2].second) > 1e-15 || (superiorStepId != -1 && fabsl(cf[2].second - load->getComponent3(superiorStepId)) > 1e-15))
            cf[2].first = "BZ";
        //场不存在
        if (!field)
        {
            //写出
            for (int i = 0; i < 3; ++i)
            {
                if (cf[i].first.isEmpty())continue;
                *stream << QString("%1, %2, %3").arg(setName).arg(cf[i].first).arg(_writer->double2String(cf[i].second, 9, 0)) << endl;
            }
            return true;
        }
        //存在场时，需要转换
        Interface::FITKAbstractFiled::FITKFieldType fieldType = field->getFieldType();
        if (fieldType == Interface::FITKAbstractFiled::FITKFieldType::FFTAnalytical)
        {
            QStringList nameList;
            QList<double> resultList;
            if (!this->getAnalyticalDataBySetData(set, Interface::FITKModelEnum::FITKModelSetType::FMSElem, nameList, resultList))
                return false;
            for (int i = 0; i < nameList.size(); ++i)
            {
                QString name = nameList.at(i);
                double result = resultList.at(i);
                for (int j = 0; j < 3; ++j)
                {
                    if (cf[j].first.isEmpty())continue;
                    *stream << QString("%1, %2, %3").arg(name).arg(cf[j].first).arg(_writer->double2String(cf[j].second * result)) << endl;
                }
            }

        }
        return true;
    }

    bool FITKAbaqusAdaptorLoad::dLoadGravityW()
    {
        //重力的数据存储
        Interface::FITKAbaLoadGravity* load = dynamic_cast<Interface::FITKAbaLoadGravity*>(_dataObj);
        if (!_writer || !_caseData || !load)return false;
        QTextStream* stream = _writer->getStream();
        QString inforString = QString("** Name: %1  Type: %2").arg(load->getDataObjectName()).arg("Gravity");
        Interface::FITKAbstractFiled* field = load->getField();
        if (field)
        {
            inforString += QString(" Using Field: %1").arg(field->getDataObjectName());
        }
        *stream << inforString << endl;
        //写出cload
        QString lineOne = "*Dload";
        if (!_op.isEmpty())
            lineOne += _op;
        //输出取消激活
        if (_stepId == -1)
        {
            *stream << lineOne << endl;
            return true;
        }
        auto ampData = _caseData->getAmplitudeManager()->getDataByID(load->getAmplitudeId(_stepId));
        if (ampData)
        {
            QString ampName = ampData->getDataObjectName();
            ampName = ampName.contains(' ') ? QString("\"%1\"").arg(ampName) : ampName;
            lineOne += QString(", amplitude=%1").arg(ampName);
        }
        *stream << lineOne << endl;
        double x = load->getComponent1(_stepId);
        double y = load->getComponent2(_stepId);
        double z = load->getComponent3(_stepId);
        double value = sqrt(x * x + y * y + z * z);
        x /= value;
        y /= value;
        z /= value;
        if (load->isWholeModel())
        {
            *stream << ", GRAV, " << _writer->double2String(value, 9, 0) << ", " << _writer->double2String(x, 9, 0) << ", " << _writer->double2String(y, 9, 0) << ", " << _writer->double2String(z, 9, 0) << endl;
            return true;
        }
        
        //获取set
        Interface::FITKModelSet* set = dynamic_cast<Interface::FITKModelSet*> (load->getComponentObj());
        if (!set)return false;
        QString setName = set->getDataObjectName();
        setName = setName.contains(' ') ? QString("\"%1\"").arg(setName) : setName;
        Interface::FITKAbstractModel* modelData = load->getModelObj();
        if (!modelData) return false;
        if (load->getModelID() != set->getAbsModelID() && modelData->getAbsModelType() == Interface::FITKModelEnum::AbsModelType::AssInstance)
        {
            QString name = load->getModelObj()->getDataObjectName();
            name = name.contains(' ') ? QString("\"%1\"").arg(name) : name;
            setName = name + "." + setName;
        }
        //场不存在
        if (!field)
        {
            *stream << setName << ", GRAV, " << _writer->double2String(value, 9, 0) << ", " << _writer->double2String(x, 9, 0) << ", " << _writer->double2String(y, 9, 0) << ", " << _writer->double2String(z, 9, 0) << endl;
            return true;
        }
        //存在场时，需要转换
        Interface::FITKAbstractFiled::FITKFieldType fieldType = field->getFieldType();
        if (fieldType == Interface::FITKAbstractFiled::FITKFieldType::FFTAnalytical)
        {
            QStringList nameList;
            QList<double> resultList;
            if (!this->getAnalyticalDataBySetData(set, Interface::FITKModelEnum::FITKModelSetType::FMSElem, nameList, resultList))
                return false;
            for (int i = 0; i < nameList.size(); ++i)
            {
                QString name = nameList.at(i);
                double result = resultList.at(i);
                *stream << name << ", GRAV, " << _writer->double2String(value * result, 9, 0) << ", " << _writer->double2String(x, 9, 0) << ", " << _writer->double2String(y, 9, 0) << ", " << _writer->double2String(z, 9, 0) << endl;
            }

        }
        return true;
    }

    bool FITKAbaqusAdaptorLoad::getAnalyticalDataBySetData(Interface::FITKModelSet* setData, int type, QStringList& nameList, QList<double>& resultList)
    {
        Interface::FITKAbaAbstractLoad* load = dynamic_cast<Interface::FITKAbaAbstractLoad*>(_dataObj);
        if (!setData || !load) return false;
        QList<Interface::FITKModelSet*> setList;
        setData->getAbsoluteSet(setList, Interface::FITKModelEnum::FITKModelSetType(type));
        if (setList.isEmpty()) return false;
        Interface::FITKFieldAanlyticalExpress* expField = dynamic_cast<Interface::FITKFieldAanlyticalExpress*>(load->getField());
        if (!expField) return false;
        Python::FITKPythonInterface* python = Python::FITKPythonInterface::getInstance();
        if (!python) return false;
        //获取表达式
        QString expression = expField->getExpression();
        //节点类型
        if (type == Interface::FITKModelEnum::FITKModelSetType::FMSNode)
        {
            for (Interface::FITKModelSet* setNodeData : setList)
            {
                if (!setNodeData) continue;
                Interface::FITKAbstractModel* modelData = setNodeData->getAbstractModel();
                if (!modelData) continue;
                QString modelName = modelData->getDataObjectName();
                modelName = modelName.contains(' ') ? QString("\"%1\"").arg(modelName) : modelName;
                //获取成员
                QList<int> idList = setNodeData->getAbsoluteMember();
                for (int id : idList)
                {
                    QString name = QString::number(id);
                    if (modelData->getAbsModelType() == Interface::FITKModelEnum::AbsModelType::AssInstance)
                        name = QString("%1.%2").arg(modelName).arg(id);
                    double coor[3]{ 0,0,0 };
                    if (!modelData->getPointCoor(id, coor)) continue;
                    QString expressionField = expression;
                    expressionField.replace("X", QString::number(coor[0]));
                    expressionField.replace("Y", QString::number(coor[1]));
                    expressionField.replace("Z", QString::number(coor[2]));
                    QVariant result;
                    bool ok = python->submit(expressionField, result);
                    if (!ok) continue;
                    nameList.append(name);
                    resultList.append(result.toDouble());
                }
            }
        }
        //单元类型
        else if (type == Interface::FITKModelEnum::FITKModelSetType::FMSElem)
        {
            for (Interface::FITKModelSet* setElemData : setList)
            {
                if (!setElemData) continue;
                Interface::FITKAbstractModel* modelData = setElemData->getAbstractModel();
                if (!modelData) continue;
                if (modelData->getAbsModelType() != Interface::FITKModelEnum::AbsModelType::AssInstance) continue;
                Interface::FITKAbstractAssInstance* instanceData = dynamic_cast<Interface::FITKAbstractAssInstance*>(modelData);
                if (!instanceData)continue;
                AbaqusData::FITKAbaqusPart* partData = dynamic_cast<AbaqusData::FITKAbaqusPart*> (instanceData->getModel());
                if (!partData) continue;
                Interface::FITKAbaMeshPartVTK* mesh = partData->getMesh();
                if (!mesh)continue;
                QString modelName = modelData->getDataObjectName();
                modelName = modelName.contains(' ') ? QString("\"%1\"").arg(modelName) : modelName;
                //获取成员
                QList<int> idList = setElemData->getAbsoluteMember();
                for (int id : idList)
                {
                    QString name = QString::number(id);
                    name = QString("%1.%2").arg(modelName).arg(id);
                    Interface::FITKAbstractElement* elemData = mesh->getElementByID(id);
                    if (!elemData) continue;
                    double coor[3]{ 0,0,0 };
                    int realNodeCount = 0;
                    int nodeCount = elemData->getNodeCount();
                    for (int i = 0; i < nodeCount; ++i)
                    {
                        double nodeCoor[3]{ 0,0,0 };
                        int nodeID = elemData->getNodeID(i);
                        if (!modelData->getPointCoor(nodeID, nodeCoor)) continue;
                        coor[0] += nodeCoor[0];
                        coor[1] += nodeCoor[1];
                        coor[2] += nodeCoor[2];
                        ++realNodeCount;
                    }
                    coor[0] /= realNodeCount;
                    coor[1] /= realNodeCount;
                    coor[2] /= realNodeCount;
                    QString expressionField = expression;
                    expressionField.replace("X", QString::number(coor[0]));
                    expressionField.replace("Y", QString::number(coor[1]));
                    expressionField.replace("Z", QString::number(coor[2]));
                    QVariant result;
                    bool ok = python->submit(expressionField, result);
                    if (!ok) continue;
                    nameList.append(name);
                    resultList.append(result.toDouble());
                }
            }
        }
        if (nameList.isEmpty() || nameList.size() != resultList.size()) return false;
        return true;
    }

    bool FITKAbaqusAdaptorLoad::getAnalyticalDataBySurfData(Interface::FITKMeshSurface* surfData, int type, QStringList& polygonStringTypeList, QStringList& nameList, QList<double>& resultList)
    {
        Interface::FITKAbaAbstractLoad* load = dynamic_cast<Interface::FITKAbaAbstractLoad*>(_dataObj);
        if (!surfData || !load) return false;
        Interface::FITKFieldAanlyticalExpress* expField = dynamic_cast<Interface::FITKFieldAanlyticalExpress*>(load->getField());
        if (!expField) return false;
        Python::FITKPythonInterface* python = Python::FITKPythonInterface::getInstance();
        if (!python) return false;
        //获取表达式
        QString expression = expField->getExpression();
        if (type == Interface::FITKMeshSurface::MeshSurfaceType::SurEle)
        {
            Interface::FITKMeshSurfaceElement* surf = dynamic_cast<Interface::FITKMeshSurfaceElement*> (surfData);
            if (!surf) return false;
            int countSet = surf->getMeshSetCount();
            for (int index = 0; index < countSet; ++index)
            {
                Interface::FITKModelSet* set = surf->getMeshSetAt(index);
                if (!set)continue;
                //获取面的索引
                Interface::FITKAbaSurfaceLabel::AbaSurfLabel polygonType = Interface::FITKAbaSurfaceLabel::AbaSurfLabel(surf->getSurfaceIndexAt(index));
                int faceIndex = -1;
                QString polygonString;
                if (polygonType == Interface::FITKAbaSurfaceLabel::AbaSurfLabel::S1)
                {
                    polygonString = "P1";
                    faceIndex = 0;
                }
                else if (polygonType == Interface::FITKAbaSurfaceLabel::AbaSurfLabel::S2)
                {
                    polygonString = "P2";
                    faceIndex = 1;
                }
                else if (polygonType == Interface::FITKAbaSurfaceLabel::AbaSurfLabel::S3)
                {
                    polygonString = "P3";
                    faceIndex = 2;
                }
                else if (polygonType == Interface::FITKAbaSurfaceLabel::AbaSurfLabel::S4)
                {
                    polygonString = "P4";
                    faceIndex = 3;
                }
                else if (polygonType == Interface::FITKAbaSurfaceLabel::AbaSurfLabel::S5)
                {
                    polygonString = "P5";
                    faceIndex = 4;
                }
                else if (polygonType == Interface::FITKAbaSurfaceLabel::AbaSurfLabel::S6)
                {
                    polygonString = "P6";
                    faceIndex = 5;
                }
                else if (polygonType == Interface::FITKAbaSurfaceLabel::AbaSurfLabel::SPOS)
                {
                    polygonString = "P";
                    faceIndex = 0;
                }
                else if (polygonType == Interface::FITKAbaSurfaceLabel::AbaSurfLabel::SNEG)
                {
                    polygonString = "P";
                    faceIndex = 1;
                }
                if (faceIndex == -1)continue;

                QList<Interface::FITKModelSet*> nodeSetList;
                set->getAbsoluteSet(nodeSetList, Interface::FITKModelEnum::FITKModelSetType::FMSElem);
                if (nodeSetList.isEmpty()) return false;
                for (Interface::FITKModelSet* setData : nodeSetList)
                {
                    if (!setData) continue;
                    Interface::FITKAbstractModel* modelData = setData->getAbstractModel();
                    if (!modelData) continue;
                    if (modelData->getAbsModelType() != Interface::FITKModelEnum::AbsModelType::AssInstance)continue;
                    Interface::FITKAbstractAssInstance* instanceData = dynamic_cast<Interface::FITKAbstractAssInstance*>(modelData);
                    if (!instanceData)continue;
                    AbaqusData::FITKAbaqusPart* partData = dynamic_cast<AbaqusData::FITKAbaqusPart*> (instanceData->getModel());
                    if (!partData) continue;
                    Interface::FITKAbaMeshPartVTK* mesh = partData->getMesh();
                    if (!mesh)continue;
                    QString modelName = modelData->getDataObjectName();
                    modelName = modelName.contains(' ') ? QString("\"%1\"").arg(modelName) : modelName;
                    //获取成员
                    QList<int> idList = setData->getAbsoluteMember();
                    for (int id : idList)
                    {
                        QString name = QString::number(id);
                        name = QString("%1.%2").arg(modelName).arg(id);
                        Interface::FITKAbstractElement* elemData = mesh->getElementByID(id);
                        if (!elemData) continue;
                        double coor[3]{ 0,0,0 };
                        int realNodeCount = 0;
                        QList<int> nodeIDList = elemData->getFace(faceIndex);
                        for (int nodeID : nodeIDList)
                        {
                            double nodeCoor[3]{ 0,0,0 };
                            if (!modelData->getPointCoor(nodeID, nodeCoor))continue;
                            coor[0] += nodeCoor[0];
                            coor[1] += nodeCoor[1];
                            coor[2] += nodeCoor[2];
                            ++realNodeCount;
                        }
                        if (realNodeCount == 0)continue;
                        coor[0] /= realNodeCount;
                        coor[1] /= realNodeCount;
                        coor[2] /= realNodeCount;
                        QString expressionField = expression;
                        expressionField.replace("X", QString::number(coor[0]));
                        expressionField.replace("Y", QString::number(coor[1]));
                        expressionField.replace("Z", QString::number(coor[2]));
                        QVariant result;
                        bool ok = python->submit(expressionField, result);
                        if (!ok) continue;
                        double resV = result.toDouble();
                        if (polygonType == Interface::FITKAbaSurfaceLabel::AbaSurfLabel::SPOS)
                            resV = 0 - resV;
                        nameList.append(name);
                        resultList.append(resV);
                        polygonStringTypeList.append(polygonString);
                    }
                }
            }
        }
        
        if (nameList.isEmpty() || nameList.size() != resultList.size() || nameList.size() != polygonStringTypeList.size()) return false;
        return true;
    }
}
